
// 文章的基本方法
pub struct Post {
    content: String,
}

// 草稿
pub struct DraftPost {
    content: String,
}

// 待审核
pub struct PendingReview {
    content: String,
}

impl Post {
    // 新建文章, 新建起来, 就是一片草稿
    pub fn new() -> DraftPost {
        DraftPost {
            content: String::new(),
        }
    }
    pub fn content(&self) -> &str {
        &self.content
    }
}

impl DraftPost {
    // 修改草稿
    pub fn add_text(&mut self, str: &str) {
        self.content.push_str(str);
    }
    // 提交审核
    pub fn request_review(self) -> PendingReview {
        PendingReview {
            content: self.content
        }
    }
}

impl PendingReview {
    // 审核通过
    pub fn approve(self) -> Post {
        Post { content: self.content }
    }
}

